/*
* BoundingRectangle.cpp
*
*  Created on: Jan 21, 2011
*      Author: Team MRF
*/

#include "BoundingRectangle.h"

namespace gsp280Project2
{
	//C001: PRIVATE DEFAULT CONSTRUCTOR
	BoundingRectangle::BoundingRectangle()
	{
		Location.setVector2(0, 0);
		this->width = 1;
		this->height = 1;

		//setting the Vertices of the Obj
		this->BL.setVector2( Location.getVector2() );
		this->BR.setVector2((BL.getX() + width), BL.getY());
		this->TL.setVector2(BL.getX(), (BL.getY() + height));
		this->TR.setVector2((TL.getX() + width), (BR.getY() + height));
	}

	//C002: OVERLOADED CONSTRUCTOR
	BoundingRectangle::BoundingRectangle ( const Vector2 &vec, const pShort width, const pShort height )
	{
		Location.setVector2(vec);
		this->width = width;
		this->height = height;

		//setting the Vertices of the Obj
		this->BL.setVector2(vec);
		this->BR.setVector2( (BL.getX() + width), BL.getY() );
		this->TL.setVector2( BL.getX(), (BL.getY() + height) );
		this->TR.setVector2( (TL.getX() + width), (BR.getY() + height) );
	}


	//==============================================
	//IMPLEMENTING SHAPE ABSTRACT CLASS METHODS.....
	//==============================================

	//M001: Get Height data member
	const pShort BoundingRectangle::getHeight ( ) const
	{
		return this->height;
	}

	//M002: Set Height data member
	void BoundingRectangle::setHeight ( const pShort &height )
	{
		this->height = height;
	}

	//M003: Get Width data member
	const pShort BoundingRectangle::getWidth ( ) const
	{
		return this->width;
	}

	//M004: Set Width data member
	void BoundingRectangle::setWidth ( const pShort &width )
	{
		this->width = width;
	}

	//M005: Calculate Obj Area
	const float BoundingRectangle::calcArea ( ) const
	{
		return ( width * height );
	}

	//M006: Set Obj Location by Vector
	void BoundingRectangle::setLocation ( const Vector2 & vect )
	{
		Location.setVector2(vect);
	}

	//M007: Set Obj Location by x,y values
	void BoundingRectangle::setLocation ( const float &_x, const float &_y )
	{
		Location.setVector2(_x, _y);
	}

	//M008: Set Obj Location_X
	void BoundingRectangle::setLocation_X ( const float &_x )
	{
		Location.setX(_x);
	}

	//M009: Set Obj Location_Y
	void BoundingRectangle::setLocation_Y ( const float &_y )
	{
		Location.setY(_y);
	}

	//M010: Get Obj Location by Vector
	const Vector2 BoundingRectangle::getLocation ( ) const
	{
		return ( Location.getVector2() );
	}

	//M011: Get Obj Location_X
	const float BoundingRectangle::getLocation_X ( ) const
	{
		return ( Location.getX() );
	}

	//M012: Get Obj Location_Y
	const float BoundingRectangle::getLocation_Y ( ) const
	{
		return ( Location.getY() );
	}

	//M013: Round float to 2 decimal places
	float BoundingRectangle::float_RoundOff2 (float value)
	{
		return (ceilf(value * 100) / 100);
	}

	//M014: Get Bottom-Left Vertex of Obj
	const Vector2 BoundingRectangle::getVertex_BL() const
	{
		return ( this->BL );
	}

	//M015: Set Bottom-Left Vertex of Obj
	void BoundingRectangle::setVertex_BL( const float &x, const float &y )
	{
		this->BL.setVector2( float_RoundOff2(x), float_RoundOff2(y) );
	}

	//M016: Get Bottom-Right Vertex of Obj
	const Vector2 BoundingRectangle::getVertex_BR ( ) const
	{
		return (this->BR);
	}

	//M017: Set Bottom-Right Vertex of Obj
	void BoundingRectangle::setVertex_BR ( const float &x, const float &y )
	{
		this->BR.setVector2(float_RoundOff2(x), float_RoundOff2(y));
	}

	//M018: Get Top-Left Vertex of Obj
	const Vector2 BoundingRectangle::getVertex_TL() const
	{
		return (this->TL);
	}

	//M019: Set Top-Left Vertex of Obj
	void BoundingRectangle::setVertex_TL( const float &x, const float &y )
	{
		this->TL.setVector2(float_RoundOff2(x), float_RoundOff2(y));
	}

	//M020: Get Top-Right Vertex of Obj
	const Vector2 BoundingRectangle::getVertex_TR () const
	{
		return (this->TR);
	}

	//M021: Set Top-Right Vertex of Obj
	void BoundingRectangle::setVertex_TR ( const float &x, const float &y )
	{
		this->TR.setVector2(float_RoundOff2(x), float_RoundOff2(y));
	}

}//namespace

